package com.qd.panda.wallet.plan;

import com.cdqidi.dto.ApiResult;
import com.cdqidi.dto.ApiResultWrapper;
import com.qd.common.sys.enums.RemoteEnum;
import com.qd.common.sys.util.SecurityUtils;
import com.qd.common.panda.domain.entity.wallet.publish.PlanPublishDTO;
import com.qd.panda.service.wallet.publish.PlanPublishService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 钱包/套餐/APP_套餐
 *
 * @author sjk
 */
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/app/wallet/planPublish/")
@Slf4j
public class AppPlanPublishController {
    private final PlanPublishService planPublishService;

    /**
     * 可选套餐
     *
     * @return 列表信息
     */
    @GetMapping(value = "/optionalPlan")
    public ApiResultWrapper<Object> optionalPlan() {
        if (!SecurityUtils.getLoginUser().getRemote().equals(RemoteEnum.MINI_PROGRAM.getCode())) {
            return ApiResult.error(401, "没有权限操作");
        }
        PlanPublishDTO planPublishDTO = planPublishService.getEnable();

        return ApiResult.success(planPublishDTO);
    }
}